package com.tsunami.message.config;

import com.tsunami.message.common.MqConstant;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author lx
 * @since 2024-09-18
 */
@Configuration
public class MailRabbitConfig {

    @Bean
    public Queue mailQueue() {
        return new Queue(MqConstant.MAIL_QUEUE_NAME, true);
    }

    @Bean
    public DirectExchange mailExchange() {
        return new DirectExchange(MqConstant.MAIL_EXCHANGE_NAME, true, false);
    }

    @Bean
    public Binding mailBinding() {
        return BindingBuilder.bind(mailQueue()).to(mailExchange()).with(MqConstant.MAIL_ROUTING_KEY_NAME);
    }
}
